package edu.ccut.saturn.authority.core.resource;

import java.util.ArrayList;
import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IAuthorityResourceInfo;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnAuthorityManager;

public class QueryResbyResIdList extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		List resourceNoList = (List)parameterContext.getParameterValue(0);
		List<IAuthorityResourceInfo> allResourceList = SaturnAuthorityManager
		.getInstance().getAllResources();
		List<IAuthorityResourceInfo> resourceListWithRole = new ArrayList<IAuthorityResourceInfo>();
		//List<IAuthorityResourceInfo> resourceListWithoutRole = new ArrayList<IAuthorityResourceInfo>();
		if (resourceNoList.size() > 0) {
			for (IAuthorityResourceInfo resourceInfo : allResourceList) {
				for (Object resourceNo : resourceNoList) {
					if (resourceNo.equals(resourceInfo.getResourceKey())) {
						resourceListWithRole.add(resourceInfo);
					}
				}
			}
		}
//		for (IAuthorityResourceInfo resourceInfo : allResourceList) {
//			if (!resourceListWithRole.contains(resourceInfo)) {
//				resourceListWithoutRole.add(resourceInfo);
//			}
//		}
		parameterContext.setParameter(1, resourceListWithRole);
		//parameterContext.setParameter(2, resourceListWithoutRole);
	}
}